//
//  IntroductionViewController.m
//  Product_NEWS
//
//  Created by dllo on 16/1/12.
//  Copyright © 2016年 FCH. All rights reserved.
//

#import "IntroductionViewController.h"

@interface IntroductionViewController ()<UIScrollViewDelegate>
@property (nonatomic, strong) UIScrollView *introductionSV;
@property (nonatomic, strong) UIPageControl *pageC;


@end

@implementation IntroductionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.introductionSV = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    UIImageView *firstImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    UIImageView *secondImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width, 0, self.view.frame.size.width, self.view.frame.size.height)];
    UIImageView *thridImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width * 2, 0, self.view.frame.size.width, self.view.frame.size.height)];
    UIImageView *fouthImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width * 3, 0, self.view.frame.size.width, self.view.frame.size.height)];
   
    
//    if (self.view.frame.size.height == 568) {
        firstImageView.image = [UIImage imageNamed:@"1.png"];
        secondImageView.image = [UIImage imageNamed:@"2.png"];
        thridImageView.image = [UIImage imageNamed:@"3.png"];
        fouthImageView.image = [UIImage imageNamed:@"4.png"];
//    }else if (self.view.frame.size.height == 667){
//        firstImageView.image = [UIImage imageNamed:@"1.png"];
//        secondImageView.image = [UIImage imageNamed:@"2.png"];
//        thridImageView.image = [UIImage imageNamed:@"3.png"];
//        fouthImageView.image = [UIImage imageNamed:@"4.png"];
//    }else if (self.view.frame.size.height == 736){
//        firstImageView.image = [UIImage imageNamed:@"1.png"];
//        secondImageView.image = [UIImage imageNamed:@"2.png"];
//        thridImageView.image = [UIImage imageNamed:@"3.png"];
//        fouthImageView.image = [UIImage imageNamed:@"4.png"];
//    }
    
    
    UIButton *enterButton = [UIButton buttonWithType:UIButtonTypeCustom];
    enterButton.frame = CGRectMake(self.view.center.x, self.view.frame.size.height - 70* SCREEN_HEIGHT, 170 * SCREEN_WIDTH, 50 *SCREEN_HEIGHT);
    enterButton.center = CGPointMake(self.view.center.x, self.view.frame.size.height - 50 * SCREEN_HEIGHT);
    [enterButton setImage:[UIImage imageNamed:@"next_page.png"] forState:UIControlStateNormal];
   
    [enterButton addTarget:self action:@selector(enterButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    fouthImageView.userInteractionEnabled = YES;
    [fouthImageView addSubview:enterButton];
    
    [self.introductionSV addSubview:fouthImageView];
    [self.introductionSV addSubview:thridImageView];
    [self.introductionSV addSubview:secondImageView];
    [self.introductionSV addSubview:firstImageView];
    
    
    
    // 宽
    self.introductionSV.contentSize = CGSizeMake(self.view.frame.size.width * 4, self.view.frame.size.height);
//    // 设置按页滑动 一页一页滑动(默认为NO)
    self.introductionSV.pagingEnabled = YES;
    // 设置滚动到边界是否有反弹效果(默认为YES)
    self.introductionSV.bounces = NO;
    // 滚动偏移量
    self.introductionSV.contentOffset = CGPointMake(0, 0);
    // 是否显示滚动条
    self.introductionSV.showsHorizontalScrollIndicator = NO;
    
    self.introductionSV.delegate = self;
 [self.view addSubview:self.introductionSV];
    
    
    
    
    
    
    // 小圆点
    self.pageC = [[UIPageControl alloc] initWithFrame:CGRectMake(40, self.view.frame.size.height - 10, 200, 10)];
    self.pageC.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.pageC];
    
    self.pageC.center = CGPointMake(self.view.center.x, self.view.frame.size.height - 10);
    
    // 设置总页数
    self.pageC.numberOfPages = 4;
    // 设置当前页码(从0开始)
    self.pageC.currentPage = 0;
    // 设置所有小圆点的颜色
    self.pageC.pageIndicatorTintColor = [UIColor whiteColor];
    // 设置当前页码颜色
    self.pageC.currentPageIndicatorTintColor = [UIColor colorWithRed:0.808 green:0.267 blue:0.251 alpha:1.000];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    self.pageC.currentPage = self.introductionSV.contentOffset.x / self.view.frame.size.width;
    
}




- (void)enterButtonAction:(UIButton *)button
{

    [self dismissViewControllerAnimated:YES completion:^{
        
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
